package org.geektimes.projects.user.service;

import org.geektimes.projects.user.domain.User;
import org.geektimes.projects.user.orm.jpa.DelegateEntityManager;

import javax.annotation.Resource;
import javax.persistence.EntityTransaction;

public class UserServiceImpl implements UserService {

    @Resource(name = "bean/DelegateEntityManager")
    private DelegateEntityManager entityManager;
//    @Resource(name = "bean/DelegateValidation")
//    private DelegateValidation validation;

    @Override
    public boolean register(User user) {
        EntityTransaction transaction = entityManager.getTransaction();
        transaction.begin();
        entityManager.persist(user);
        transaction.commit();
        return true;
    }

    @Override
    public boolean deregister(User user) {
        return false;
    }

    @Override
    public boolean update(User user) {
        return false;
    }

    @Override
    public User queryUserById(Long id) {
        return null;
    }

    @Override
    public User queryUserByNameAndPassword(String name, String password) {
        return null;
    }
}
